From a681f36c2e14c3660d7a0f1f59d5c3d1fe408be5 Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Fri, 19 Nov 2010 13:20:48 +0000 Subject: [PATCH] x86/mm: don't override an existing shadow memory allocation when enabling log-dirty shadows on a PV guest. Signed-off-by: Tim Deegan --- xen/arch/x86/mm/shadow/common.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/xen/arch/x86/mm/shadow/common.c b/xen/arch/x86/mm/shadow/common.c index 143a2d73d8..7a8627c587 100644 --- a/xen/arch/x86/mm/shadow/common.c +++ b/xen/arch/x86/mm/shadow/common.c @@ -3311,17 +3311,23 @@ static int shadow_one_bit_enable(struct domain *d, u32 mode) mode |= PG_SH_enable; - if ( d->arch.paging.mode == 0 ) + if ( d->arch.paging.shadow.total_pages == 0 ) { - /* Init the shadow memory allocation and the hash table */ - if ( sh_set_allocation(d, 1, NULL) != 0 - || shadow_hash_alloc(d) != 0 ) + /* Init the shadow memory allocation if the user hasn't done so */ + if ( sh_set_allocation(d, 1, NULL) != 0 ) { sh_set_allocation(d, 0, NULL); return -ENOMEM; } } + if ( d->arch.paging.mode == 0 ) + { + /* Init the shadow hash table */ + if ( shadow_hash_alloc(d) != 0 ) + return -ENOMEM; + } + /* Update the bits */ sh_new_mode(d, d->arch.paging.mode | mode); -- 2.30.2